/**
 * Created by chang on 2017/8/28.
 */
$(function () {
    var token = localStorage.getItem("token");
    var username = localStorage.getItem("userName");
    if(token){
        $(".center .right #personal").html("欢迎! "+username);

        $(".center .right #login ").css("display","none");
        $(".center .right #quit").css("display","inline-block");
        $(".center .right #personal").css("display","inline-block");
        $(".center .right #register").css("display","none");
        $(".center .right #quit").click(function () {
            Comm().logout();
            $(".center .right #register").css("display","inline-block");
            $(".center .right #login ").css("display","inline-block");
            $(".center .right #quit").css("display","none");
            $(".center .right #personal").css("display","none");
        })
    }
    //输入框加入键盘enter事件
    $('#seek_shop').bind('keypress', function (e) {
        if (e.keyCode == "13") {
            var searchText = jQuery.trim($("#seek_shop").val());
            console.log(searchText);
            var searchUrl = encodeURI("/template/goods.html?searchText=" + searchText); //使用encodeURI编码
            location.href = searchUrl;
            return false;
        }
    });
    //把商品加入购物车
    // $('.joinCart').click(function () {
    //     var goodid = $(this).attr('id');
    //     goodid = goodid.replace('goodid','');
    //     console.log(goodid);
    // });
});